/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.biblioteca.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dsw2.biblioteca.modelo.Libro;

/**
 *
 * @author Juan Carlos
 */
@Stateless
public class LibroDao extends AbstractDao<Libro> implements LibroDaoLocal {
    @PersistenceContext(unitName = "Biblioteca8e-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public LibroDao() {
        super(Libro.class);
    }
    
        
    @Override
    public boolean findByDuplicity(Libro book){
        Query q = em.createNamedQuery("Libro.findByIsbn");
        q.setParameter("clave", book.getClave());
        return !q.getResultList().isEmpty();
    }
    
}
